package com.yami.shop.controller;

import com.yami.shop.bean.model.MeltCloudUsergroup;
import com.yami.shop.common.response.ServerResponseEntity;
import com.yami.shop.dto.group.UserGroupDTO;
import com.yami.shop.service.impl.RongYunUsergroupServiceImpl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 超级群用户组
 */
@RestController
@RequestMapping("/p/im/ultraGroup/usergroup")
@Schema(description = "app-超级群用户组")
@AllArgsConstructor
public class RongYunUserGroupController {
    
    private final RongYunUsergroupServiceImpl usergroupService;

    @PostMapping("/create")
    @Operation(summary =  "创建用户组")
    public ServerResponseEntity create(@RequestBody UserGroupDTO param) throws Exception {
        return usergroupService.create(param);
    }

    @PostMapping("/delete")
    @Operation(summary =  "删除用户组")
    public ServerResponseEntity delete(@RequestBody UserGroupDTO param) throws Exception {
        return usergroupService.delete(param);
    }
    
    @GetMapping("/get")
    @Operation(summary =  "获取用户组")
    public ServerResponseEntity<List<MeltCloudUsergroup>> getByGroupId(@RequestParam Long groupId) throws Exception {
        return usergroupService.getByGroupId(groupId);
    }

    @PostMapping("/addUser")
    @Operation(summary =  "用户组添加用户")
    public ServerResponseEntity addUser(@RequestBody UserGroupDTO param) throws Exception {
        return usergroupService.addUser(param);
    }

    @PostMapping("/delUser")
    @Operation(summary =  "移除用户组成员")
    public ServerResponseEntity delUser(@RequestBody UserGroupDTO param) throws Exception {
        return usergroupService.delUser(param);
    }

    @GetMapping("/getByUserId")
    @Operation(summary =  "获取用户的用户组")
    public ServerResponseEntity getByUserId(@RequestParam Long groupId, @RequestParam String userId) throws Exception {
        return usergroupService.getByUserId(groupId, userId);
    }

    @PostMapping("/bindChannel")
    @Operation(summary =  "绑定用户组与频道")
    public ServerResponseEntity bind(@RequestBody UserGroupDTO param) throws Exception{
        return usergroupService.bind(param);
    }

    @PostMapping("/unbindChannel")
    @Operation(summary =  "解绑用户组与频道")
    public ServerResponseEntity unbind(@RequestBody UserGroupDTO param) throws Exception{
        return usergroupService.unbind(param);
    }

    @GetMapping("/getByChannelId")
    @Operation(summary =  "获取频道绑定的用户组")
    public ServerResponseEntity queryUserGroup(@RequestParam Long groupId, @RequestParam String channelId){
        return usergroupService.queryUserGroup(groupId, channelId);
    }

    @GetMapping("/getChannel/byUserGroupId")
    @Operation(summary =  "获取用户组绑定的频道")
    public ServerResponseEntity queryChannel(@RequestParam Long groupId, @RequestParam Long userGroupId) {
        return usergroupService.queryChannel(groupId, userGroupId);
    }




}
